package com.vois.jack.btmgr.devices.F1Dev;

/**
 *
 * Created by Administrator on 2017/7/18.
 *
 */

/**
 *    头域
 *    msgseq:char 消息序号0~255
 *    blocktype:2bit 消息类型 0:notify 1:request 2:resposne
 *    blockmark:2bit 消息块标识 0:首包 1:中间包 2:结束包 3:不分包
 *    blockseq:4bit 消息块序号0~15 当消息超过MTU时分块传输
 *
 *    josn一级结构
 *    t:业务类型
 *    b:业务数据 根据业务类型对应二级json结构
 *    {"t":int,"b":""}
 *
 *    t:业务类型定义
 *    0:添加Wifi(req<->rsp)
 *    1:删除Wifi(req<->rsp)
 *    2:修改AP名称(req<->rsp)
 *    3:获取Wifi列表(req<->rsp)
 *    4:Wifi信息(notify)
 *    6:心跳(req<->rsp)
 *   7:Ready(notify)
 *   8:Wifi列表传送完成(notify)
 *
 *    业务数据
 *    t:0 添加Wifi
 *    "b":{"n":"Wifi Mac地址","p":"Wifi密码"}
 *
 *    t:1 删除Wifi
 *    "b":{"n":"Wifi Mac地址"}
 *
 *    t:2 修改AP名称
 *    "b":{"n":"AP名称","p":"AP密码长度8位以上"}
 *
 *    t:3 获取Wifi列表
 *    "b":""
 *
 *    t:4 Wifi信息
 *    "b":{"n":"Wifi名称","a":"Wifi Mac地址","l":Wifi信息强度,"f":WIFI频率(2400),"p":是否加密(0不是,1是),"c":是否为当前连接(0不是,1是)}
 *
 *    t:6 心跳
 *    "b":""
 *
 *    t:7 Ready
 *    "b":""
 *
 *    t:8 Wifi列表传送完成
 *    "b":""
 */


public class Wl400NetworkConfigData {
    //蓝牙名前缀
    public static final String WL400_BLE_START_STR = "WL-";
    //服务UUID，读写都采用utf-8编码
    public static final String SERVICE_UUID = "0000f613-0000-1000-8000-00805f9b34fb";
    //APP向WL400传送配置信息 json 封装 WriteWl400NetworkConfig.
    public static final String WRITE_CHARACTERISTIC_UUID = "0000f413-0000-1000-8000-00805f9b34fb";
    //APP读取WL400附近WiFi信息，WL400 返回 json 封装 ReadWl400WifiInfoResult
    public static final String READ_CHARACTERISTIC_UUID = "0000f513-0000-1000-8000-00805f9b34fb";
    //设备版本信息服务UUID
    public static final String SERVICE_DEVICE_INFORMATION = "0000180a-0000-1000-8000-00805f9b34fb";
    public static final String DEVICE_CHARACTERISTIC_UUID = "00002a28-0000-1000-8000-00805f9b34fb";

    public static final int WL400_BLE_MTU = 203;
    public static final int WL400_DEFAULT_BLE_MTU = 23;

    public static final int WL400_BLE_TRUE = 1;
    public static final int WL400_BLE_FALSE = 0;

    //业务类型
    public static final int ADD_WIFI_CONFIG_TYPE = 0;  //添加WIFI
    public static final int DEL_WIFI_CONFIG_TYPE = 1;  //删除WIFI
    public static final int MODIFY_AP_CONFIG_TYPE = 2; //修改WL400当AP时的名称（Wl400WifiInfo.SSID）及密码(WriteWl400NetworkConfig.password)
    public static final int GET_WIFI_LIST_TYPE = 3; //取WIFI信息
    public static final int NOTIFY_WIFI_INFO_TYPE = 4;  //通知WIFI信息
    public static final int HEARTBEAT_TYPE = 6;  //心跳
    public static final int NOTIFY_WL400_READY_TYPE = 7;  //通知400准备就绪
    public static final int NOTIFY_SEND_WIFI_LIST_COMPLETED_TYPE = 8;  //通知WIFI列表传送完成了

    public static class Wl400BleData {
        private int t;
        private String b;

        public int getConfigType() {
            return t;
        }

        public String getContent() {
            return b;
        }

        @Override
        public String toString() {
            return "Wl400BleRequest{" +
                    "type=" + t +
                    ", content='" + b + '\'' +
                    '}';
        }
    }

    public static class Wl400WifiInfo implements java.io.Serializable{
        private String n;//The network name.
        private String a;//The address of the access point.
        private int p;//是否加密
        private int l;//信号强度 -100 ~ -55.
        private int f; //频率 2.4G(freq > 2400 && freq < 2500), 5G(freq > 4900 && freq < 5900).
        private int c; //当前连接;

        public Wl400WifiInfo(String SSID, String BSSID, int capabilities, int level, int frequency, int isCurrentConnect) {
            this.n = SSID;
            this.a = BSSID;
            this.p = capabilities;
            this.l = level;
            this.f = frequency;
            this.c = isCurrentConnect;
        }

        public String getSSID() {
            return n;
        }

        public String getBSSID() {
            return a;
        }

        public int getCapabilities() {
            return p;
        }

        public int getLevel() {
            return l;
        }

        public int getFrequency() {
            return f;
        }

        public int isCurrentConnect() {
            return c;
        }


        @Override
        public String toString() {
            return "Wl400WifiInfo{" +
                    "SSID='" + n + '\'' +
                    ", BSSID='" + a + '\'' +
                    ", capabilities='" + p + '\'' +
                    ", level=" + l +
                    ", frequency=" + f +
                    ", isCurrentConnect=" + c +
                    '}';
            }
    }

    public static class Wl400NetworkConfigInfo {
        private String n;
        private String p;

        public Wl400NetworkConfigInfo(String name, String password) {
            this.n = name;
            this.p = password;
        }

        public String getName() {
            return n;
        }

        public String getPassword() {
            return p;
        }
    }
}
